/**
 * @Author：ming
 * @Date：2023/10/5 11:36 PM
 * @Filename：Lc122
 */

/**
 * @author ming
 */
public class Lc122 {
    public int maxProfit(int[] prices) {
        int max = 0;
        int profit =0;
        int len = prices.length;

        int price = prices[0];
        for (int i = 0; i < len; i++) {
            if(prices[i]>price){
                profit = prices[i]-price;
                max += profit;
            }
           price = prices[i];
        }

        return max;
    }
}
